<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>开单财务对账</title>
    <% include("/common/common_css_js.html"){} %>
  </head>
  <body>
        <div style="padding-bottom: 5px;">
          <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">
            <span>分单号:</span><input id="keyBillCode" name="keyBillCode" emptyText="请输入分单号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="分单号不能为空" />
            <span class="separator"></span>
            <span>分单归属部门:</span>
            <input id="keyAttributionDepartmentId" name="keyAttributionDepartmentId" class="mini-treeselect" style="width:250px;" textField="name" valueField="id" emptyText="请选择..."
                   expandOnLoad="2"  virtualScroll="true"  multiSelect = "true"  showFolderCheckBox="true"
                   required="false" allowInput="true" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择归属部门"/>
            <span class="separator"></span>
            <span>运输种类:</span><input id="keyTransportSpeciesId" name="keyTransportSpeciesId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                     required="false" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择运输种类" onvaluechanged="transportSpeciesIdChange" />
            <span class="separator"></span>
            <span>承运方式:</span><input id="keyTransportWayId" name="keyTransportWayId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                     required="false" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择承运方式"/>

            <div style="margin-top: 5px"></div>
            <span>发货人:</span>
            <div id="keyDeliveryCustomerId" name="keyDeliveryCustomerId" class="mini-autocomplete" style="width:250px;"  popupWidth="1000" textField="name" valueField="id"
                 url="${base}/pages/customer_manage/queryDeliveryCustomerByKey"  required="false" requiredErrorText="发货人不能为空"
                 searchField="key"
                 emptyText="发货人名称">
              <div property="columns">
                <div header="ID" field="id" width="30"></div>
                <div header="客户名称" field="name"></div>
                <div header="客户简称" field="shortName"></div>
                <div header="客户电话" field="phone"></div>
                <div header="客户地址" field="address"></div>
              </div>
            </div>

            <span class="separator"></span>
            <span>收货人:</span>
            <input id="keyReceiveCustomerName" name="keyReceiveCustomerName" style="width:250px;"  emptyText="收货人名称"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="收货人名称不能为空"/>

            <span class="separator"></span>
            <span>提货点:</span>
            <div id="airCk" name="airCk" class="mini-checkbox" readOnly="false" text="航空" onvaluechanged="ckChanged"></div>
            <div id="autoCk" name="autoCk" class="mini-checkbox" readOnly="false" text="汽运" onvaluechanged="ckChanged"></div>
            <div id="keyPickUpPointId" name="keyPickUpPointId" class="mini-combobox" style="width:350px;"  popupWidth="800" textField="name" valueField="id"
                 multiSelect="true"  showClose="true" oncloseclick="keyPickUpPointIdCloseClick" >
                <div property="columns">
                  <div header="类型" field="pickUpTypeId" width="60" data-options='{cacheName:"sysDic"}' renderer="commonRender"></div>
                  <div header="提货点名称" field="name" width="150"></div>
                  <div header="提货点电话" field="phone" width="150"></div>
                  <div header="提货点地址" field="address" width="200"></div>
                </div>
            </div>


            <span class="separator"></span>
            <span>提货方式:</span>
            <input id="keyPickUpGoodsWayId" name="keyPickUpGoodsWayId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                   required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择提货方式"/>

            <div style="margin-top: 5px"></div>

            <span>开单日期:</span>
            <input id="keyOpenBillStartDate" name="keyOpenBillStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>--<input id="keyOpenBillEndDate" name="keyOpenBillEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>


            <span class="separator"></span>
            <span>发货人付款方式:</span>
            <input id="keyDeliveryCustomerPaymentMethodId" name="keyDdeliveryCustomerPaymentMethodId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                   required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择发货人付款方式" />
            <span class="separator"></span>

            <span>收货人付款方式:</span>
            <input id="keyReceiveCustomerPaymentMethodId" name="keyReceiveCustomerPaymentMethodId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                   required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择收货人付款方式" />


            <div style="margin-top: 5px"></div>

            <% if(so.hasPermission("bNativeBillCw:query") || so.hasPermission("cwNativeBill:query")){%>
              <a class="mini-button" iconCls="icon-search" onclick="searchBill()">查询</a>
            <% } %>

            <% if(so.hasPermission("bNativeBillCw:queryCndClear") || so.hasPermission("cwNativeBill:queryCndClear")){%>
              <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
            <% } %>

            <% if(so.hasPermission("bNativeBillCw:confirm")){%>
              <span class="separator"></span>
              <a class="mini-button" iconCls="icon-lock" onclick="accountStatusChange(432)">确认对账</a>
            <% } %>

            <% if(so.hasPermission("bNativeBillCw:cancel")){%>
              <span class="separator"></span>
              <a class="mini-button" iconCls="icon-unlock" onclick="accountStatusChange(431)">取消对账</a>
            <% } %>

            <% if(so.hasPermission("bNativeBillCw:download") || so.hasPermission("cwNativeBill:download")){%>
              <span class="separator"></span>
              <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="客户对账表"/>
            <% } %>

          </div>
        </div>

        <div class = "mini-fit">
          <div id="datagrid1" class="mini-datagrid"
               style="width: 100%; height: 100%;"
               url="${base}/pages/native_bill_manage/queryBill" idField="id"
               showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
               allowResize="true"
               multiSelect = "true"
               showGroupsSummary="true" showSummaryRow="true" summaryPosition="bottom"
               allowSortColumn = "true"
               sortField="createTime"
               sortOrder="desc"
               ondrawsummarycell="summaryRight" >
            <div property="columns">
              <div type="checkcolumn" ></div>
              <div field="accountCheckStatusId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">对账状态</div>
              <div field="openBillDate" width="140" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">开单日期</div>
              <div field="id" width="140" headerAlign="center" align="center" allowSort="true" renderer="showNativeBillRender">分单号</div>
              <div field="attributionDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">归属部门</div>
              <div field="billLoadMasterBillIds" width="140" headerAlign="center" align="left" allowSort="true">主单号</div>
              <div field="flightName" width="140" headerAlign="center" align="center" allowSort="true">班次号</div>
              <div field="airportId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airport"}' renderer="commonRender">始发机场</div>
              <div field="destCityId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"city"}' renderer="commonRender">目的市</div>

              <div field="goodsName" width="140" headerAlign="center" align="center" allowSort="true" >货物名称</div>
              <div field="totalNumber" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">总件数</div>
              <div field="actualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实际重量</div>
              <div field="chargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">计费重量</div>
              <div field="weightRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer">重量费率</div>
              <div field="transportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">运费合计</div>
              <div field="openBillDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">开单送货费</div>

              <div field="agentDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代理送货费</div>
              <div field="serviceCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">业务费</div>
              <div field="insuranceFee" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">保费</div>
              <div field="otherCharges" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">其他费用</div>
              <div field="totalAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总金额</div>
              <div field="actualAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实收金额</div>
              <div field="dropAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">调整金额(拉货)</div>
              <div field="settlementAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">结算金额(实收金额+调整金额)</div>
              <div field="deliveryCustomerName" width="140" headerAlign="center" align="center" allowSort="true">发货人名称</div>
              <div field="receiveCustomerName" width="140" headerAlign="center" align="center" allowSort="true">收货人名称</div>
              <div field="receiveCustomerAddress" width="140" headerAlign="center" align="center" allowSort="true">收货人地址</div>
              <div field="deliveryCustomerSalemanId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysUser"}' renderer="commonRender">业务员</div>

              <div field="deliveryCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">发货人付款方式</div>
              <div field="deliveryCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">发货人付款金额</div>
              <div field="receiveCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">收货人付款方式</div>
              <div field="receiveCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">收货人付款金额</div>

              <div field="pickUpPointName" width="140" headerAlign="center" align="center" allowSort="true">提货点名称</div>
              <div field="pickUpPointPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">提货点电话</div>
              <div field="otherChargesComment" width="140" headerAlign="center" align="center" allowSort="false">其他费用说明</div>

              <!--          <div field="attributionDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">归属部门</div>-->
    <!--          <div field="transportSpeciesId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">运输种类</div>-->
    <!--          <div field="transportWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">承运方式</div>-->
    <!--          <div field="transportScopeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">运输范围</div>-->
    <!--          <div field="cityId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"city"}' renderer="commonRender">营业部所在城市</div>-->

    <!--          <div field="deliveryCustomerId" width="140" headerAlign="center" align="center" allowSort="true">发货人ID</div>-->
    <!--          <div field="deliveryCustomerPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">发货人电话</div>-->
    <!--          <div field="deliveryCustomerAddress" width="140" headerAlign="center" align="center" allowSort="true">发货人地址</div>-->

    <!--          <div field="deliveryCustomerContactId" width="140" headerAlign="center" align="center" allowSort="true">发货人联系人ID</div>-->
    <!--          <div field="deliveryCustomerContactName" width="140" headerAlign="center" align="center" allowSort="true">发货人联系人名称</div>-->
    <!--          <div field="deliveryCustomerContactPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">发货人联系人电话</div>-->

    <!--          <div field="receiveCustomerPhone" width="140" headerAlign="center" align="center" allowSort="true">收货人电话</div>-->

    <!--          <div field="pickUpPointId" width="140" headerAlign="center" align="center" allowSort="true">提货点ID</div>-->
    <!--          <div field="pickUpPointName" width="140" headerAlign="center" align="center" allowSort="true">提货点名称</div>-->
    <!--          <div field="pickUpPointPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">提货点电话</div>-->
    <!--          <div field="pickUpPointAddress" width="140" headerAlign="center" align="center" allowSort="true">提货点地址</div>-->
    <!--          <div field="pickUpGoodsWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">提货方式</div>-->

    <!--          <div field="signChooseId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">签收方式</div>-->
    <!--          <div field="flightDate" width="140" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd" renderer="ondayRenderer">班次日期</div>-->
    <!--          <div field="flightNo" width="140" headerAlign="center" align="center" allowSort="true">班次号ID</div>-->
    <!--          <div field="airlinesId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airlines"}' renderer="commonRender">航空公司</div>-->
    <!--          <div field="planTakeOffTime" width="140" headerAlign="center" align="center" allowSort="true">计划出发时间</div>-->
    <!--          <div field="goodsTypeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>-->
    <!--          <div field="packingWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">包装方式</div>-->

    <!--          <div field="volumeInformation" width="140" headerAlign="center" align="center" allowSort="true">体积信息</div>-->
    <!--          <div field="weightRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer">重量费率</div>-->
    <!--          <div field="volume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">体积</div>-->
    <!--          <div field="volumeRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer">体积费率</div>-->
    <!--          <div field="ticketPrice" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer"  summaryType="sum">起票价</div>-->
    <!--          <div field="transportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">运费合计</div>-->

    <!--          <div field="declaredValue" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">声明价值</div>-->
    <!--          <div field="insuranceRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >保费费率</div>-->

    <!--          <div field="agentDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代理送货费</div>-->
    <!--          <div field="deliveryChargeComment" width="140" headerAlign="center" align="left" allowSort="false">送货费备注</div>-->
    <!--          <div field="tax" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">税金</div>-->
    <!--          <div field="fuelSurcharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">燃油费</div>-->
    <!--          <div field="collectionMoney" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代收款</div>-->
    <!--          <div field="actualTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实收运费</div>-->

    <!--          <div field="businessCostAllocationId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">是否分摊业务费</div>-->
    <!--          <div field="businessCostAllocationTypeId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">业务费分摊类型</div>-->
    <!--          <div field="businessCostComment" width="140" headerAlign="center" align="center" allowSort="false">业务费备注</div>-->

    <!--          <div field="printActualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单实际重量</div>-->
    <!--          <div field="printChargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >打单计费重量</div>-->
    <!--          <div field="printWeightRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单重量费率</div>-->
    <!--          <div field="printVolume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单体积</div>-->
    <!--          <div field="printVolumeRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >打单体积费率</div>-->

    <!--          <div field="innerOperationCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">内部操作费</div>-->
    <!--          <div field="deliveryCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">发货人付款方式</div>-->
    <!--          <div field="deliveryCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">发货人付款金额</div>-->
    <!--          <div field="receiveCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">收货人付款方式</div>-->
    <!--          <div field="receiveCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">收货人付款金额</div>-->


    <!--          <div field="cashierId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">收银员</div>-->
    <!--          <div field="openBillUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">开单人</div>-->

    <!--          <div field="openBillDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">开单部门</div>-->
    <!--          <div field="rollCallDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">点到部门</div>-->
    <!--          <div field="comment" width="140" headerAlign="center" align="center" allowSort="false">备注</div>-->

    <!--          <div field="billLoadStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">配载状态</div>-->
    <!--          <div field="businessCostStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">业务费状态</div>-->
    <!--          <div field="agentDeliveryChargeStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">代理送货费状态</div>-->
    <!--          <div field="arrearsStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">分单欠款状态</div>-->
    <!--          <div field="dropStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">拉货状态</div>-->
    <!--          <div field="accountCheckStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">对账状态</div>-->
    <!--          <div field="settlementStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">结算状态</div>-->

    <!--          <div field="cancelStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">作废状态</div>-->

    <!--          <div field="shareCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">分摊成本</div>-->
    <!--          <div field="operatingCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">操作费</div>-->
    <!--          <div field="grossProfit" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">毛利润</div>-->

    <!--          <div field="createTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">创建时间</div>-->
    <!--          <div field="createUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">创建用户</div>-->
    <!--          <div field="updateTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">更新时间</div>-->
    <!--          <div field="updateUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">更新用户</div>-->

            </div>
          </div>
        </div>

        <script type="text/javascript">

          mini.parse();

          let keyBillCode = mini.get("keyBillCode");
          let keyAttributionDepartmentId = mini.get("keyAttributionDepartmentId");
          let keyTransportSpeciesId = mini.get("keyTransportSpeciesId");
          let keyTransportWayId = mini.get("keyTransportWayId");
          let keyDeliveryCustomerId = mini.get("keyDeliveryCustomerId");
          let keyReceiveCustomerName = mini.get("keyReceiveCustomerName");
          let keyPickUpPointId = mini.get("keyPickUpPointId");
          let keyPickUpGoodsWayId = mini.get("keyPickUpGoodsWayId");
          let keyOpenBillStartDate = mini.get("keyOpenBillStartDate");
          let keyOpenBillEndDate = mini.get("keyOpenBillEndDate");

          let keyDeliveryCustomerPaymentMethodId = mini.get("keyDeliveryCustomerPaymentMethodId");
          let keyReceiveCustomerPaymentMethodId = mini.get("keyReceiveCustomerPaymentMethodId");

          let airCk = mini.get("airCk");
          let autoCk = mini.get("autoCk");

          let grid = mini.get("datagrid1");

          $(function () {

            let keyAttributionDepartmentIdJsonData = commonRenderDropList("department");
            keyAttributionDepartmentId.loadList(keyAttributionDepartmentIdJsonData,"id","pid");

            // 运输种类下拉列表
            let transportSpeciesIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_SPECIES");
            keyTransportSpeciesId.load(transportSpeciesIdJsonData);

            // 承运方式下拉列表
            let transportWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_WAY");
            keyTransportWayId.load(transportWayIdJsonData);

            // 提货方式下拉列表
            let pickUpGoodsWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_PICK_UP_GOODS_WAY");
            keyPickUpGoodsWayId.load(pickUpGoodsWayIdJsonData);

            // 发货人付款方式
            let keyDeliveryCustomerPaymentMethodIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_DELIVERY_CUSTOMER_PAYMENT_METHOD");
            keyDeliveryCustomerPaymentMethodId.load(keyDeliveryCustomerPaymentMethodIdJsonData);

            // 收货人付款方式
            let keyReceiveCustomerPaymentMethodIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_RECEIVE_CUSTOMER_PAYMENT_METHOD");
            keyReceiveCustomerPaymentMethodId.load(keyReceiveCustomerPaymentMethodIdJsonData);

            // 提货点
            pushPickUpPointIdArray();

            clearSearch()

            // 加载列表数据
            grid.load();
          });

          function clearSearch(){
            let form = new mini.Form("#queryForm");
            form.clear();
          }

          let cancelStatus = {notCanceled:411, canceled:412}

          /**
           * 根据查询条件查询分单
           * 410,0,作废状态,作废状态,XT_DIC_CANCEL_STATUS
           411,410,未作废,未作废,
           412,410,已作废,已作废,
           */

          function searchBill(){
            let form = new mini.Form("#queryForm");
            let data = form.getData(true);
            // 一定是未作废的单子
            data.keyCancelStatusId = cancelStatus.notCanceled;
            grid.load(data);
          }

          function showNativeBillRender(e){
            let nativeBillId = e.value;
            let htmlStr = "<a href='javascript:void(0);' onclick='showViewNativeBill(\""+ nativeBillId +"\")'>" + nativeBillId + "</a>";
            return htmlStr;
          }

          function showViewNativeBill(nativeBillId){
            let tabUrl="${base}/pages/native_bill_manage/showUpdateBill?opType=view&id=" + nativeBillId;
            parent.window.addTabToMainPage("分单查看","分单查看",tabUrl);
          }

          /**
           * 30,0,提货点类型,提货点类型,XT_DIC_PICK_UP_TYPE
           31,30,航空,航空,""
           32,30,汽运,汽运,""
           */
          let pickUpType = {air:31,auto:32};

          // 清空提货点选择
          function keyPickUpPointIdCloseClick(e){
            let obj = e.sender;
            obj.setText("");
            obj.setValue("");
          }

          let airPickUpTypeArray = [];
          let autoPickUpTypeArray = [];
          let pickUpPointIdAllArray = [];
          function pushPickUpPointIdArray(){
            let pickUpPointIdArray = commonRenderDropList("pickUpPoint");
            for(let obj of pickUpPointIdArray){
              if(obj.pickUpTypeId == pickUpType.air){
                airPickUpTypeArray.push(obj);
              }
              else{
                autoPickUpTypeArray.push(obj);
              }
            }

            for(let obj of airPickUpTypeArray){
              pickUpPointIdAllArray.push(obj);
            }

            for(let obj of autoPickUpTypeArray){
              pickUpPointIdAllArray.push(obj);
            }

            //keyPickUpPointId.load(pickUpPointIdAllArray);

          }

          function ckChanged(){
            let autoCkValue = autoCk.getValue();
            let airCkValue = airCk.getValue();
            // 都是 false
            if(airCkValue == 'false' && autoCkValue == 'false'){
              keyPickUpPointId.load([]);
            }

            if(airCkValue == 'false' && autoCkValue == 'true'){
              keyPickUpPointId.load(autoPickUpTypeArray);
            }

            if(airCkValue == 'true' && autoCkValue == 'false'){
              keyPickUpPointId.load(airPickUpTypeArray);
            }

            if(airCkValue == 'true' && autoCkValue == 'true'){
              keyPickUpPointId.load(pickUpPointIdAllArray);
            }

          }

          /**
           *
           * 350,0,分单配载状态,分单配载状态,XT_DIC_BILL_LOAD_STATUS
           * NO_LOAD(351, "未配载", "未配载"),
           * PART_LOAD(352, "部分配载", "部分配载"),
           * ALL_LOAD(353, "全部配载", "全部配载");

           * 320,0,结算状态,结算状态,XT_DIC_SETTLEMENT_STATUS
           * 321,320,未结算,未结算,""
           * 322,320,已结算,已结算,""
           *
           *
           * 430,0,分单主单对账状态,分单主单对账状态,XT_DIC_ACCOUNT_CHECK_STATUS
           * 431,430,未对账,未对账,
           * 432,430,已对账,已对账,

           */

          let loadStatus = {noLoad:351, partLoad:352, allLoad:353};

          let settlementStatus = {uncleared:321, cleared:322};

          let accountCheckStatus = {noCheck:431, checked:432};


          function accountStatusChange(accountStatus){
            let selectItems = grid.getSelecteds();
            if(selectItems.length==0){
              showAlert("请选择需要改变对账状态的分单!");
              return;
            }

            // 前端过滤，对已经完成配载且没有对账没有结算的分单进行对账状态修改
            // 需要注意的如果是已经结算过的分单是不能进行对账取消的
            let canAccountCheckIds = "";
            let canNotAccountCheckIds = "";

            if(accountStatus == accountCheckStatus.checked){
              for(let obj of selectItems){
                if(obj.billLoadStatusId != loadStatus.allLoad || obj.cancelStatusId == cancelStatus.canceled){
                  canNotAccountCheckIds += obj.id + " ";
                }
                else{
                  canAccountCheckIds += "'" + obj.id + "',";
                }
              }
            }
            else{
              for(let obj of selectItems){
                if(obj.settlementStatusId == settlementStatus.cleared){
                  canNotAccountCheckIds += obj.id + " ";
                }
                else{
                  canAccountCheckIds += "'" + obj.id + "',";
                }
              }
            }

            if(canNotAccountCheckIds.length>0){
              canNotAccountCheckIds = canNotAccountCheckIds.substring(0,canNotAccountCheckIds.length-1);
              if(accountStatus == accountCheckStatus.checked){
                showAlert("选择的对账分单【" + canNotAccountCheckIds + "】没有全部配载或已经作废，不能进行对账确认操作!");
              }
              else{
                showAlert("选择的对账分单【" + canNotAccountCheckIds + "】已结算，不能进行对账取消操作!");
              }
              return;
            }

            let title = accountStatus == accountCheckStatus.checked?"确认对账?":"取消对账?";
            canAccountCheckIds = canAccountCheckIds.substring(0,canAccountCheckIds.length-1);
            // 给出确认提示框
            mini.confirm("确定为分单【" + canAccountCheckIds + "】"+ title, "对账提示",
                    function (action) {
                      if (action == "ok") {
                        let ret = public_getServerData("${base}/pages/native_bill_manage/changeAccountCheckStatus",{billIds:canAccountCheckIds,accountCheckStatusId:accountStatus});
                        showAlert(ret.message,function (){
                          if(ret.ok){
                            grid.reload();
                          }
                        });
                      }
                    }
            );
          }



          /**
           * 设置底部统计样式
           * @param e
           */
          function summaryRight(e){
            e.cellStyle="text-align:right;color:red;font-size:18px;font-weight:bold";
          }


        </script>

  </body>
</html>